<!doctype html>
<html>
<head>
<meta charset="utf8">
<link rel="help" href="https://url.spec.whatwg.org/#dom-urlsearchparams">
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script>
var expectedValues = {
    'a': '1',
    'b': '2',
    'c': '3'
};

var params = new URLSearchParams();
params.append('a', '1');
params.append('b', '2');
params.append('c', '3');

test(function() {
    for (var param of params) {
        var key = param[0];
        var value = param[1];
        assert_true(key in expectedValues);
        assert_equals(params.get(key), expectedValues[key]);
        assert_equals(value, expectedValues[key]);
    }
}, 'for...of Iteration');

test(function() {
    for (var key of params.keys()) {
        assert_true(key in expectedValues);
        assert_equals(params.get(key), expectedValues[key]);
    }
}, 'keys');

test(function() {
    var expectedKeys = {};
    for (var key in expectedValues)
        expectedKeys[expectedValues[key]] = key;

    for (var value of params.values())
        assert_true(value in expectedKeys);
}, 'values');

test(function () {
    for (var param of params.entries()) {
        var key = param[0];
        var value = param[1];
        assert_true(key in expectedValues);
        assert_equals(params.get(key), expectedValues[key]);
        assert_equals(value, expectedValues[key]);
    }
}, 'entries');

test(function () {
    params.forEach(function (value, key, paramsObject) {
        assert_true(key in expectedValues);
        assert_equals(params.get(key), expectedValues[key]);
        assert_equals(value, expectedValues[key]);
        assert_equals(paramsObject, params);
    });
}, 'forEach');
</script>
</head>
</html>
